﻿<rules>
  <rule id="Entry.Core.1027" category="core" target="entry" specificationsection ="2.2.6.3.3" requirementlevel="may" format="json" metadata="true">
    <description>If the EntityType is not part of an inheritance hierarchy, then the "type" name/value pair MAY be included.</description>
    <action processor="xslt+jsonschema">
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
        <xsl:template match="/">
          {
          "additionalProperties" : false,
          "type" : "object",
          "properties" : {

          "d" : {
          <!-- Set additionalProperties to true to allow any other object other than Property -->
          "additionalProperties" : true,
          "type" : "object",
          "properties" : {
          <xsl:apply-templates select="*[local-name()='Edmx']/*[local-name()='DataServices']/*[local-name()='Schema']/*[local-name()='EntityType'][@Name='$ENTITYTYPE$']"/>
          }
          }

          }
          }
        </xsl:template>
        <xsl:template match="*[local-name()='Edmx']/*[local-name()='DataServices']/*[local-name()='Schema']/*[local-name()='EntityType'][@Name='$ENTITYTYPE$']">
          "__metadata" : {
          "additionalProperties" : true,
          "type" : "object",
          "properties" : {
          <!-- Check to see if the entitytype is part of an inheritance hierarchy or not -->
          <xsl:if test="not(@BaseType != '')">
            "type" : { "type" : "string", "enum" : ["$NSENTITYTYPE$"], "required" : false },
          </xsl:if>
          }
          }

          }
          }
        </xsl:template>
      </xsl:stylesheet>
    </action>
  </rule>
</rules>